package views;

import java.awt.BorderLayout;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import presenters.FreqUserReportPresenter;
import presenters.RevenueReportPresenter;

public class FreqUserReportPanel extends JPanel {
	FreqUserReportPresenter myPresenter;
	JTable table;
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3960536754643630799L;

	public FreqUserReportPanel() {
		String[] columnNames = {"Username",
                "Driving Plan",
                "No Resv Month",
		};
		
		Object[][] data = {
				{"1","1","1"}
			};
		
		table = new JTable(data, columnNames);
		add(new JScrollPane(table), BorderLayout.CENTER);
		myPresenter = new FreqUserReportPresenter(this);
	}

	public void addData(ResultSet rs) {
		/*
		try{
			
			ArrayList<Object> newData = new ArrayList<Object>();
			rs.first();
			String username = rs.getString("USERNAME");
			String drivePlan = rs.getString("DRIVING_PLAN");
			String numResv = rs.getString("NO_MONTH_RESV");
			newData.add(username);
			newData.add(drivePlan);
			newData.add(numResv);
			
			while(rs.next()) {
			String username = rs.getString("USERNAME");
			String drivePlan = rs.getString("DRIVING_PLAN");
			String numResv = rs.getString("NO_MONTH_RESV");
			newData.add(username);
			newData.add(drivePlan);
			newData.add(numResv);
			}
			
		addInData = new Object[newData.size()/3][2];
		int k = 0;
		for (int i = 0; i < newData.size()/3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				addInData[i][j] = newData.get(k);
				k++;
			}
		}
		table = new JTable(addInData, columnNames);
		revalidate();
				
				
			}
		} catch(SQLException e) {
			e.printStackTrace();
		}
		
	*/
		
	}

	public FreqUserReportPresenter getMyPresenter() {
		// TODO Auto-generated method stub
		return myPresenter;
	}
}
